<?php
class M_khoahoc extends CI_Model
{
    public $data;
	public function __construct()
	{
		parent::__construct();
		// Your own constructor code
	}
    public function insertmon($ten_mon, $nganh, $tinchi){
        $data = array();
        $data['ten_mon'] = $ten_mon;
        $data['nganh'] = $nganh;
        $data['tinchi'] = $tinchi;        
        if($this->db->insert('mon',$data)){
            return true;
        }else {
            return false;
        }
    }
  
	 public function insertKhoahoc($ten, $noidung, $tl, $time, $mon, $giangvien, $nganh){
	   $nganh=$this->db->insert_id();
        $data = array();
        $data['ten_khoahoc'] = $ten;
        $data['noidung'] = $noidung;
        $data['thoi_luong'] = $tl;
        $data['time_start'] = $time;
        $data['id_mon'] = $mon;
        $data['giang_vien'] = $giangvien;
        $data['id_nganh'] = $nganh;
        if($this->db->insert('khoahoc',$data)){
            return true;
        }else {
            return false;
        }
    }
    public function insertBaigiang($tenbai, $noidung, $images, $video, $tailieu, $link, $ngay, $state, $idkhoahoc){
        $data = array();
        $data['ten_bai'] = $tenbai;
        $data['noidung'] = $noidung;
        $data['images'] = $images;
        $data['video'] = $video;
        $data['tailieu'] = $tailieu;
        $data['link'] = $link;
        $data['ngay'] = $ngay;
        $data['state'] = $state;
        $data['id_khoahoc'] = $idkhoahoc;
        
        if($this->db->insert('baigiang',$data)){
            return true;
        }else {
            return false;
        }
    }
	public function get_select()
    {     
        $this->db->select('*');
        $this->db->from('mon');
        $result = $this->db->get();
        return $result;
        $result->free_result();
    }
 }